#!/usr/bin/env bash
set -eu
. common
set -- ${cli_trace2line:-} "$@"
while getopts a: OPT; do
  case "$OPT" in
    a)
      arch="$OPTARG"
      ;;
  esac
done
set_common_vars "$arch" false
kernel_dir="${build_dir}/linux-custom"
sed -E 's/.*pc=//' "${qemu_out_dir}/trace.txt" | \
  xargs "${host_dir}/bin/${arch}-linux-addr2line" -e "${kernel_dir}/vmlinux" -fp | \
  sed -E "s|at ${kernel_dir}/(\./\|)||" | \
  uniq -c \
> "${qemu_out_dir}/trace-lines.txt"
